package com.ruoyi.quartz.task;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.hqfinance.domain.HqBillData;
import com.ruoyi.hqfinance.domain.vo.HqBillDataShowVo;
import com.ruoyi.hqfinance.service.HqBillCollectService;
import com.ruoyi.logistic.domain.HqBillCollectCardAndSevenCache;
import com.ruoyi.logistic.mapper.HqBillCollectCardAndSevenCacheMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletResponse;

/**
 * @Author cmz
 * @Date 2024-06-27 19:36
 */
@Component("cacheTask")
public class CacheTask {

    @Autowired
    private HqBillCollectService hqBillCollectService;
    @Autowired
    private HqBillCollectCardAndSevenCacheMapper hqBillCollectCardAndSevenCacheMapper;
    
    public void cardAndSevenCache()
    {
        Integer[] collectTypes = {1,2,3};
        String[] settleNetworkNameIds = {"辽宁盘锦公司"};
        String[] sevenMarks = {"all"};
        HqBillDataShowVo vo;
        for (Integer collectType : collectTypes) {
            for (String settleNetworkNameId : settleNetworkNameIds) {
                for (String sevenMark : sevenMarks) {
                    vo = new HqBillDataShowVo();
                    vo.setCollectType(collectType);
                    vo.setSettleNetworkNameId(settleNetworkNameId);
                    vo.setSevenMark(sevenMark);
                    HqBillData data = hqBillCollectService.data(vo);

                    byte[] result = JSON.toJSONString(data).getBytes();
                    HqBillCollectCardAndSevenCache cache = new HqBillCollectCardAndSevenCache();
                    cache.setCollecttype(collectType);
                    cache.setSettleNetworkNameId(settleNetworkNameId);
                    cache.setSevenmark(sevenMark);
                    cache.setRespData(result);

                    hqBillCollectCardAndSevenCacheMapper.insertSelective(cache);

                }
            }
        }
    }
}
